Ext.onReady(function() {

    var store = Ext.create('Ext.data.TreeStore', {
        autoLoad: true,
        proxy: {
            type: 'ajax',
            url: 'MenuListJson.action'
        }
    });

    var treePanel = Ext.create("Ext.tree.Panel", {
        rootVisible: false,
        title: '功能菜单',
        region: 'west',
        width: 250,
        split: true,
        collapsible: true,
        store: store,
        useArrows: true,
        listeners: {
            itemclick: function(v, r, item) {
                if (r.raw.leaf) {
                    clickTree(r);
                }
            }
        }
    });

    treePanel.expandAll();


    Ext.create('Ext.container.Viewport', {
        layout: 'border',
        frame: false,
        items: [{
                region: 'center',
                xtype: 'panel',
                frame: false,
                layout: 'border',
                items: [treePanel, {
                        region: 'center',
                        id: 'accessPanel',
                        title: '车辆管理系统',
                        html: '<iframe name="frame" id="frame"  width=100% height=100% frameborder=0></iframe>'
                    }, {
                        region: 'north',
                        height: 57,
                        frame: false,
                        html: '<div style="width:100%;height:100%;"><div id="app-header-title" style="right: auto; left: 0px; margin: 0px; width: 100%; top: 2px;padding: 22px 50px 10px 56px;color: white;font-size: 18px;font-weight: bold;text-shadow: 0 1px 0 #4e691f;">车辆管理系统<label style="float: right"><font style="color: #157fcc">' + username + '</font>   您好！欢迎登录！&nbsp;&nbsp;&nbsp;<a href="' + basePath + 'static/logout.jsp" style="float:right;color: white;">退出</a></label></div></div>'
                    }]
            }]

    });

    function clickTree(record) {
        Ext.getCmp("accessPanel").setTitle(record.raw.text);
        document.getElementById("frame").src = record.raw.url + "?access=" + record.raw.access;
    }
});